package com.pb.infra.auth.controller;

import com.pb.infra.oth.entity.common.Result;
import com.pb.infra.auth.entity.pbsys.PriviLine;
import com.pb.infra.auth.service.PriviLineService;
import com.pb.infra.oth.util.Constant;
import com.pb.infra.oth.util.SysLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
 * 条线管理
 *
 * @author liudebao
 * @date 2020/12/25
 */
@Slf4j
@RestController
@RequestMapping("v1/system/line")
public class PriviLineController {

    /**
     * 日志操作表
     */
    private static final String TABLE_NAME = "PRIVI_LINE";

    /**
     * 日志操作功能名
     */
    private static final String OPERATION_MENU = "条线管理";

    /**
     * 业务逻辑对象
     */
    @Resource
    PriviLineService priviLineService;

    /**
     * 查询条线
     * @param paramMap 请求参数
     * @return Result 返回数据
     */
    @GetMapping("select")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result select(@RequestParam Map<String, Object> paramMap, HttpServletRequest request) {
        return priviLineService.select(paramMap, request);
    }
    /**
     * 新建条线
     *
     * @param priviLine 请求参数
     * @return Result 返回数据
     */
    @PostMapping("insert")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.ADD, menuName = OPERATION_MENU)
    public Result insert(@RequestBody PriviLine priviLine, HttpServletRequest request) {
        return priviLineService.insert(priviLine, request);
    }
    /**
     * 修改条线
     *
     * @param priviLine 请求参数
     * @return Result 返回数据
     */
    @PostMapping("update")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.MOD, menuName = OPERATION_MENU)
    public Result update(@RequestBody PriviLine priviLine, HttpServletRequest request) {
        priviLineService.update(priviLine, request);
        return Result.OK_EMPTY;
    }

    /**
     * 删除条线
     *
     * @param paramMap 请求参数
     * @return Result 返回数据
     */
    @PostMapping("delete")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.DEL, menuName = OPERATION_MENU)
    public Result delete(@RequestBody List<String> paramMap) {
        priviLineService.delete(paramMap);
        return Result.OK_EMPTY;
    }

}
